<?php
session_start();
include 'fungsi.php';
$id = $_GET['id'];

	if($_POST['btnsimpan']=="Update")
	{ 
		$judul = $_POST['judul'];
		$tanggal = date('Y-m-d');
		$deskripsi = $_POST['deskripsi'];
		if($judul=="" and $deskripsi=="")
		{
			echo"<script>alert('Data harus diisi !');</script>";
		}else{  
		   
			$baru = new fungsi();
			$baru->konek();
			$sql="update informasi_malang set judul_artikel=' ".$judul." ', tanggal=' ".$tanggal." ', deskripsi=' ".$deskripsi." ' where id_info=' ".$id." ' ";
			mysql_query($sql);
			if(mysql_errno() == 0)
			{
?>
			<script>alert('Data berhasil diupdate !');</script>
<?php				
				
				$page = "home_adm.php?log=".$_SESSION['username'];
				$hasil=$baru->redirectPage($page);
				echo $hasil;
				
				
			}else{
				  echo"<script>alert('Data gagal diupdate !');</script>";
			  }
		}
	}else{

			$baru = new fungsi();
			$konek = $baru->konek();
			$sql= "SELECT * FROM informasi_malang WHERE id_info = '".$id."'";
			var_dump($sql);
			$result = mysql_query($sql);
				if(mysql_num_rows($result) > 0)
				{
					while($data = mysql_fetch_array($result))
					{
					  $judul = $data['judul_artikel'];
					  $tanggal = date('Y-m-d');
					  $deskripsi = $data['deskripsi'];
					}
				}
		}
?>
<html lang="en">
<head>
	<link type="text/css" rel="stylesheet" href="css/bootstrap.css"/>
</head>
<header>  
<title>Jajanan Ngalam</title>
	<div class="hero-unit" style="margin-left:70px; margin-top:70px; margin-right:80px">
		<h1><font face="comic sans MS" color="green">JAJANAN NGALAM</font></h1>
		<p><font face="comic sans MS" size=4> Website Integrasi pedagang jajanan asli kota Malang </font></p>
	</div>
</header>
<body>
<div class="hero-unit" style="width:80%; height:auto; margin-left:70px;">
	<div class="container-fluid">
		<div class="row-fluid">
			<div class="row">
				<div class="span9">	
					<div class="navbar">
						<div class="navbar-inner" style="margin-left:20; margin-right:20">
						<a class="brand">ADMIN</a>
							<ul class="nav">
								<li><a href="home_adm.php" > Info Malang</a></li>
								<li><a href="Daftar_akun.php" >Akun Pengguna </a></li>
								<li><a href="Daftar_produk.php" >Produk Kami</a></li>
								<li><a >Lokasi Kuliner</a></li>
								<li><a >Kritik dan Saran</a></li>
							</ul>
						</div>
						<div class="container-fluid">
							<div class="well span12">
									<a>
											<table class="table">
													
														
															<form action="" method="post">
															
															 <tr>
																<td>Judul Artikel</td>
																<td>
																   <input type="text" name="judul" value="<?php echo"$judul"; ?>" />
																</td>
															</tr>
															<tr>
																<td>Deskripsi</td>
																<td>
																	<textarea rows="25" class="span8" name="deskripsi"><?php echo "$deskripsi"; ?></textarea>
																   <!--<input type="text" name="deskripsi" value="<?php echo"$deskripsi"; ?>"/>-->
																</td>
															</tr>
															<td colspan="2" align="right">
																   <input type="submit" name="btnsimpan" value="Update" />
																</td>
														  
														  
																
															 
														 </form>
														
													
											</table>
									</a>
								
									
							
									
							</div>
							
						</div>	
					</div>	
				</div>	
				<div class="span3">
					<div class="well"></div>
				</div>
			</div>
		</div>
	</div>
</div>
	<script src="js/bootstrap.min.js"></script>
	<script src="js/bootstrap.js"></script>
	<script src="js/bootstrap-tab.js"></script>
</body>
<footer>
	<div class="hero-unit" style="margin-left:70px; margin-bottom:70px; margin-right:80px">
	</div>
</footer>
</html>
